package com.rocsea.robot.controller;

import com.rocsea.robot.model.request.BatchSwitchDatasourceRequest;
import com.rocsea.robot.model.request.EtlSyncCheckConfigBuildRequest;
import com.rocsea.robot.service.KettleExtService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author RocSea
 * @Date 2022/7/11
 */
@RestController
@RequestMapping("ext/build")
public class KettleExtController {
    @Resource
    private KettleExtService kettleExtService;

    @ApiOperation(value = "生成检查配置")
    @PostMapping("check/config")
    @ResponseBody
    public String autoBuild(@RequestBody EtlSyncCheckConfigBuildRequest request) {
        return kettleExtService.autoBuild(request);
    }

    @ApiOperation(value = "格式化sqlserver建表语句")
    @PostMapping("format/mss")
    public String formatMss(@RequestBody String request) {
        return kettleExtService.formatMss(request);
    }

    @ApiOperation(value = "支持批量切换数据源")
    @PostMapping("switch/datasource")
    public String switchDatasource(@RequestBody BatchSwitchDatasourceRequest request) {
        return kettleExtService.switchDatasource(request);
    }
}
